/**
 * 
 */
package metalink.admin;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;

import model.admin.LibraryMo;

import vo.LibraryBookDetailsVo;

import com.opensymphony.xwork2.ActionSupport;

/**
 * @author Sony
 * 
 */
public class AddBook extends ActionSupport {
	ArrayList<String> title = new ArrayList<String>(),
			author = new ArrayList<String>(),
			description = new ArrayList<String>(),
			numberOfBooks = new ArrayList<String>(),
			price = new ArrayList<String>(),
			referredby = new ArrayList<String>(),
			publisher = new ArrayList<String>(),
			category = new ArrayList<String>();

	String submit = "";
	ArrayList<LibraryBookDetailsVo> bookCategories;

	public String execute() {

		LibraryMo mo = new LibraryMo();
		bookCategories = new ArrayList<LibraryBookDetailsVo>();
		bookCategories = mo.bookList();

		if (submit.equals("submit")) {
			LibraryBookDetailsVo vo = new LibraryBookDetailsVo();
			vo.setAuthor_name_list(author);
			Iterator<String> i = category.iterator();
			while (i.hasNext())
			{
			    String s = i.next();
			    if (s == null || s.isEmpty()||s.equals(""))
			    {
			        i.remove();
			    }
			}
			vo.setCategory_list(category);
			vo.setBook_name_list(title);
			vo.setCount_list(numberOfBooks);
			vo.setDescription_list(description);
			vo.setPrice_list(price);
			vo.setReferred_by_list(referredby);
			vo.setPublisher_list(publisher);
			mo = new LibraryMo();
			mo.addBook(vo,"AddNewBook");
			
			LibraryMo mo1 = new LibraryMo();
			bookCategories = new ArrayList<LibraryBookDetailsVo>();
			bookCategories = mo1.bookList();
		}

		return SUCCESS;
	}

	public ArrayList<String> getPrice() {
		return price;
	}

	public void setPrice(ArrayList<String> price) {
		this.price = price;
	}

	public ArrayList<String> getReferredby() {
		return referredby;
	}

	public void setReferredby(ArrayList<String> referredby) {
		this.referredby = referredby;
	}

	public ArrayList<String> getPublisher() {
		return publisher;
	}

	public void setPublisher(ArrayList<String> publisher) {
		this.publisher = publisher;
	}

	public String getSubmit() {
		return submit;
	}

	public void setSubmit(String submit) {
		this.submit = submit;
	}

	public ArrayList<String> getCategory() {
		return category;
	}

	public void setCategory(ArrayList<String> category) {
		this.category = category;
	}

	public ArrayList<String> getTitle() {
		return title;
	}

	public void setTitle(ArrayList<String> title) {
		this.title = title;
	}

	public ArrayList<String> getAuthor() {
		return author;
	}

	public void setAuthor(ArrayList<String> author) {
		this.author = author;
	}

	public ArrayList<String> getDescription() {
		return description;
	}

	public void setDescription(ArrayList<String> description) {
		this.description = description;
	}

	public ArrayList<String> getNumberOfBooks() {
		return numberOfBooks;
	}

	public void setNumberOfBooks(ArrayList<String> numberOfBooks) {
		this.numberOfBooks = numberOfBooks;
	}

	public ArrayList<LibraryBookDetailsVo> getBookCategories() {
		return bookCategories;
	}

	public void setBookCategories(ArrayList<LibraryBookDetailsVo> bookCategories) {
		this.bookCategories = bookCategories;
	}

}
